var app = getApp(), imgArray = [], uploaded = [];

Page({
    data: {
        hidden1: !1,
        hidden2: !0,
        hidden3: !0,
        index: 0,
		index2: 0,
        index_two: 0,
		e_index:0,
		w_index:0,
		s_index:0,
		s2_index:0,
		sex_index:1,
		public_index:1,
		m_index:0,
        prompt: !1,
        choise: !1,
        images: [],
        upload_img: [],
		resume_info:[],
        upload_img_length: 0,
		hotel_logo:'',
		education_key: [ "1", "2", "3", "4", "5", "6", "7", "8", "9"],
		education_value: [ "小学", "初中", "高中", "中专", "大专", "本科", "硕士", "博士", "博士后"],
		working_key : [ "1","2","3","4","5"],
		working_value : [ "1年","2年","3年","4年","5年以上"],
		status_key : [ "1","2","3"],
		status_value : ["目前已离职，可快速上岗","目前无跳槽打算","目前在职，考虑换工作"],
		style_key : [ "1","2","3"],
		style_value : [ "全职","兼职","实习"],
		money_key : [ "1","2","3","4"],
		money_value : ["1000-3000","3000-5000","5000-10000","10000以上"],
		sex_arr : [
			 {name: '男', value: '1', checked: 'true'},
			 {name: '女', value: '2'}
		],
		public_arr : [
			 {name: '是', value: '1', checked: 'true'},
			 {name: '否', value: '2'}
		],
    },
	bindMultiPickerChange: function(e) {
        console.log("picker发送选择改变，携带值为", e.detail.value), this.setData({
            multiIndex: e.detail.value
        });
    },
    onLoad: function(e) {
        var o = this;
        wx.setNavigationBarColor({
            frontColor: "#ffffff",
            backgroundColor: wx.getStorageSync("color"),
            animation: {
                duration: 0,
                timingFunc: "easeIn"
            }
        }), console.log(o.data);
        var t = wx.getStorageSync("url2"), a = wx.getStorageSync("openid"), n = wx.getStorageSync("users").id;
        console.log("用户的openid为 " + a + " 用户的user_id为 " + n), app.util.request({
            url: "entry/wxapp/GetUserInfo",
            cachetime: "0",
            data: {
                user_id: n
            },
            success: function(e) {
				
            }
        }), o.setData({
            user_id: n,
            openid: a,
            url: t
		}), app.util.request({
            url: "entry/wxapp/type2",
            cachetime: "0",
			data: {
                id: 11
            },
            success: function(e) {
                console.log(e), 0 == e.data.length && (wx.showModal({
                    title: "提示",
                    content: "请选择职位"
                }), setTimeout(function() {
                    wx.navigateBack({});
                }, 2e3));
                var t = e.data, a = [] , a2 = [];
                t.map(function(e) {
                    var t,t2;
                    t = e.name, t2 = e.id , a.push(t) , a2.push(t2);
                }), o.setData({
                    store: t,
                    store_type: a,
					store_type_id: a2,
                })
            }
        }),app.util.request({
			url: "entry/wxapp/MyResume",
            cachetime: "0",
            data: {
                user_id: n
            },
            success: function(e) {
				if(e.data) {
					var n = wx.getStorageSync("url");
					var type_id = o.data.store_type_id;
					var i = 0;
					var j = 0;
					type_id.map(function(t) {
						if(t == e.data.curr_position) {
							o.setData({
								index:i
							})
						}
						if(t == e.data.go_position) {
							o.setData({
								index2:j
							})
						}
						i++,j++;
					});
					o.setData({
                        resume_info: e.data,
						e_index:e.data.education,
						w_index:e.data.work_year,
						s_index:e.data.curr_status,
						s2_index:e.data.style,
						m_index:e.data.money,
						hotel_logo:e.data.person_logo,
						url1:n
                    })
					if(e.data.sex == 2) {
						var sex_arr = [
							 {name: '男', value: '1'},
							 {name: '女', value: '2',checked: 'true'}
						];
						o.setData({
							sex_arr:sex_arr
						})
					}
					if(e.data.is_public == 2) {
						var sex_arr = [
							 {name: '是', value: '1'},
							 {name: '否', value: '2',checked: 'true'}
						];
						o.setData({
							public_arr:public_arr
						})
					}					
				};
			}
        });
    },
	radioChange: function(e) {
		console.log('radio发生change事件，携带value值为：', e.detail.value)
		this.setData({
		  sex_index: e.detail.value
		})
	},
	publicChange: function(e) {
		console.log('radio发生change事件，携带value值为：', e.detail.value)
		this.setData({
		  public_index: e.detail.value
		})
	},
	bindEduChanges: function(e) {
		console.log('picker发送选择改变，携带值为', e.detail.value)
		this.setData({
		  e_index: e.detail.value
		})
   },
   bindWorkChanges: function(e) {
		console.log('picker发送选择改变，携带值为', e.detail.value)
		this.setData({
		  w_index: e.detail.value
		})
   },
   bindStatusChanges: function(e) {
		console.log('picker发送选择改变，携带值为', e.detail.value)
		this.setData({
		  s_index: e.detail.value
		})
   },
   bindStyleChanges: function(e) {
		console.log('picker发送选择改变，携带值为', e.detail.value)
		this.setData({
		  s2_index: e.detail.value
		})
   },
   bindMoneyChanges: function(e) {
		console.log('picker发送选择改变，携带值为', e.detail.value)
		this.setData({
		  m_index: e.detail.value
		})
   },
    bindPickerChanges: function(e) {
        var t = this, a = t.data.store, o = e.detail.value;
        this.setData({
            index: o,
            index_two: 0
        })
    },
	bindPickerChanges2: function(e) {
        var t = this, a = t.data.store, o = e.detail.value;
        this.setData({
            index2: o,
            index_two: 0
        })
    },
    bindchange_two: function(e) {
        this.setData({
            index_two: e.detail.value
        });
    },
    bindRegionChange: function(e) {
        this.setData({
            inde: e.detail.value
        });
    },
    choice: function(e) {
        this.setData({
            choice: !0
        });
    },
    previewImage: function(e) {
        var t = e.currentTarget.dataset.index, a = this.data.lunbo;
        wx.previewImage({
            current: a[t],
            urls: a
        });
    },
    choose: function(e) {
        var a = this, o = a.data.url, n = wx.getStorageSync("uniacid"),u = wx.getStorageSync("url");
        console.log(o), console.log(n), wx.chooseImage({
            count: 1,
            sizeType: [ "original", "compressed" ],
            sourceType: [ "album", "camera" ],
            success: function(e) {
                console.log(e);
                var t = e.tempFilePaths[0];
                wx.uploadFile({
                    url: o + "app/index.php?i=" + n + "&c=entry&a=wxapp&do=Upload&m=zh_tcwq",
                    filePath: t,
                    name: "upfile",
                    formData: {},
                    success: function(e) {
                        console.log(e), a.setData({
                            hotel_logo: e.data
                        });
                    },
                    fail: function(e) {
                        console.log(e);
                    }
                }), a.setData({
					url1: u,
                    hotel_logo: t
                });
            }
        });
    },
    checkboxChange: function(e) {
        console.log(e);
        var t = e.detail.value;
        this.setData({
            facilities: t
        });
    },
    chooseImage2: function() {
        var o = this, n = this.data.images;
        imgArray = [], console.log(o.data);
        var i = wx.getStorageSync("uniacid"), e = 9 - n.length;
        0 < e && e <= 9 ? wx.chooseImage({
            count: e,
            sizeType: [ "compressed" ],
            sourceType: [ "album", "camera" ],
            success: function(e) {
                wx.showToast({
                    icon: "loading",
                    title: "正在上传"
                });
                var t = e.tempFilePaths;
                console.log(t);
                var a = e.tempFilePaths;
                n = n.concat(a), console.log(n), o.setData({
                    images: n,
                    lunbo_len: n.length
                }), o.uploadimg({
                    url: o.data.url + "app/index.php?i=" + i + "&c=entry&a=wxapp&do=Upload&m=zh_tcwq",
                    path: n
                });
            }
        }) : wx.showModal({
            title: "上传提示",
            content: "最多上传9张图片",
            showCancel: !0,
            cancelText: "取消",
            confirmText: "确定",
            success: function(e) {},
            fail: function(e) {},
            complete: function(e) {}
        });
    },
    uploadimg: function(e) {
        var t = this, a = e.i ? e.i : 0, o = e.success ? e.success : 0, n = e.fail ? e.fail : 0;
        wx.uploadFile({
            url: e.url,
            filePath: e.path[a],
            name: "upfile",
            formData: null,
            success: function(e) {
                "" != e.data ? (console.log(e), o++, imgArray.push(e.data), console.log(a), console.log("上传商家轮播图时候提交的图片数组", imgArray)) : wx.showToast({
                    icon: "loading",
                    title: "请重试"
                });
            },
            fail: function(e) {
                n++, console.log("fail:" + a + "fail:" + n);
            },
            complete: function() {
                console.log(a), ++a == e.path.length ? (t.setData({
                    images: e.path
                }), wx.hideToast(), console.log("执行完毕"), console.log("成功：" + o + " 失败：" + n)) : (console.log(a), 
                e.i = a, e.success = o, e.fail = n, t.uploadimg(e));
            }
        });
    },
    delete: function(e) {
        console.log(this.data), console.log(imgArray), Array.prototype.indexOf = function(e) {
            for (var t = 0; t < this.length; t++) if (this[t] == e) return t;
            return -1;
        }, Array.prototype.remove = function(e) {
            var t = this.indexOf(e);
            -1 < t && this.splice(t, 1);
        };
        var t = e.currentTarget.dataset.index, a = this.data.images;
        imgArray.remove(imgArray[t]), a.remove(a[t]), console.log(a), this.setData({
            images: a,
            lunbo_len: a.length
        });
    },
    upload_image: function() {
        var a = this, o = this.data.upload_img;
        uploaded = [], console.log(o);
        var n = wx.getStorageSync("uniacid"), e = 9 - o.length;
        0 < e && e <= 9 ? wx.chooseImage({
            count: e,
            sizeType: [ "compressed" ],
            sourceType: [ "album", "camera" ],
            success: function(e) {
                wx.showToast({
                    icon: "loading",
                    title: "正在上传"
                });
                var t = e.tempFilePaths;
                o = o.concat(t), console.log(o), a.setData({
                    upload_img: o,
                    upload_img_length: o.length
                }), a.already({
                    url1: a.data.url + "app/index.php?i=" + n + "&c=entry&a=wxapp&do=Upload&m=zh_tcwq",
                    path1: o
                });
            }
        }) : wx.showModal({
            title: "上传提示",
            content: "最多上传9张图片",
            showCancel: !0,
            cancelText: "取消",
            confirmText: "确定",
            success: function(e) {},
            fail: function(e) {},
            complete: function(e) {}
        });
    },
    already: function(e) {
        var t = this, a = e.j ? e.j : 0, o = e.success ? e.success : 0, n = e.fail ? e.fail : 0;
        wx.uploadFile({
            url: e.url1,
            filePath: e.path1[a],
            name: "upfile",
            formData: null,
            success: function(e) {
                "" != e.data ? (console.log(e), o++, uploaded.push(e.data), t.setData({
                    uploaded: uploaded
                }), console.log(a), console.log("上传商家介绍时候提交的图片数组", uploaded)) : wx.showToast({
                    icon: "loading",
                    title: "请重试"
                });
            },
            fail: function(e) {
                n++, console.log("fail:" + a + "fail:" + n);
            },
            complete: function() {
                console.log(a), ++a == e.path1.length ? (t.setData({
                    upload_img: e.path1
                }), wx.hideToast(), console.log("执行完毕"), console.log("成功：" + o + " 失败：" + n)) : (console.log(a), 
                e.j = a, e.success = o, e.fail = n, t.already(e));
            }
        });
    },
    delete2: function(e) {
        Array.prototype.indexOf = function(e) {
            for (var t = 0; t < this.length; t++) if (this[t] == e) return t;
            return -1;
        }, Array.prototype.remove = function(e) {
            var t = this.indexOf(e);
            -1 < t && this.splice(t, 1);
        };
        var t = e.currentTarget.dataset.index, a = this.data.upload_img;
        uploaded.remove(uploaded[t]), a.remove(a[t]), console.log(a), this.setData({
            upload_img: a,
            upload_img_length: a.length
        });
    },
    formSubmit: function(e) {
        var a = this;
		var var_t = e.detail.value.true_name;
		var var_t2 = e.detail.value.title;
		var var_t3 = e.detail.value.birth;
		var var_t4 = e.detail.value.whereat;
		var var_t5 = e.detail.value.address;
		var var_t6 = e.detail.value.phone;
		var var_t7 = e.detail.value.textarea;
		var var_t8 = a.data.hotel_logo;
		if(var_t == "" || var_t2 == "" || var_t3 == "" || var_t4 == "" || var_t5 == "" || var_t6 == "" || var_t7 == "" || var_t8 == "") {
			wx.showModal({
				title: "提示",
				content: "数据填写不完整",
				showCancel: !0,
				cancelText: "取消",
				confirmText: "确定",
				success: function(e) {},
				fail: function(e) {},
				complete: function(e) {}
			 });
		} else {
			 var o = wx.getStorageSync("openid");
			 app.util.request({
				url: "entry/wxapp/resume",
				cachetime: "0",
				data: {
					user_id: a.data.user_id,
					true_name:var_t,
					title:var_t2,
					sex:a.data.sex_index,
					birth:var_t3,
					whereat:var_t4,
					education:a.data.education_key[a.data.e_index],
					work_year:a.data.working_key[a.data.w_index],
					curr_status:a.data.status_key[a.data.s_index],
					style:a.data.style_key[a.data.s2_index],
					money:a.data.money_key[a.data.m_index],
					address:var_t5,
					phone:var_t6,
					curr_position:a.data.store[a.data.index]['id'],
					go_position:a.data.store[a.data.index2]['id'],
					is_public:a.data.public_index,
					person_logo:var_t8,
					content:var_t7,
					form_id:e.detail.formId,
					open_id:o
				},
				success: function(e) {
					 wx.showModal({
						title: "提示",
						content: "简历提交成功"
					}), setTimeout(function() {
						wx.reLaunch({
							url: "../logs/logs",
							success: function(e) {},
							fail: function(e) {},
							complete: function(e) {}
						});
					}, 2e3);
				}
			 })
		}
    },
    reset: function(e) {},
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {}
});